#include <QHBoxLayout>
#include <QVBoxLayout>
#include <QHeaderView>
#include "functioneditorwidget.h"
#include "functionsview.h"
#include "functionsmodel.h"
#include "functionedit.h"

FunctionEditorWidget::FunctionEditorWidget(FunctionsModel *model,QWidget *parent):QWidget(parent)
{
    QVBoxLayout * vLayout = new QVBoxLayout;
    QHBoxLayout  *hLayout = new QHBoxLayout;

    funcsView = new FunctionsView(this);
    funcsView->setModel(model);
    funcsView->header()->resizeSections(QHeaderView::ResizeToContents);
    funcsView->setSelectionMode(QAbstractItemView::SingleSelection);
    funcsView->setRootIsDecorated(false);
    funcsView->setSortingEnabled(false);
    funcsView->setColumnWidth(0,50);

    okButon = new QPushButton(QString(tr("Tạo")));
    deleteButton = new QPushButton(QString(tr("Xóa")));

    hLayout->addWidget(okButon);
    hLayout->addWidget(deleteButton);

    stackedWidget = new QStackedWidget(this);
    QWidget * nonWidget = new QWidget;
    stackedWidget->addWidget(nonWidget);

    funced = new FunctionEdit(this);
    stackedWidget->addWidget(funced);

    stackedWidget->setCurrentIndex(0);
    vLayout->addWidget(funcsView);
    vLayout->addLayout(hLayout);
    vLayout->addWidget(stackedWidget);
    deleteButton->setEnabled(false);

    setLayout(vLayout);
}
